/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package dao.impl;

import dao.NhomSanPhamDAO;
import java.util.List;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import pojo.NhomSanPham;

/**
 *
 * @author pvhuy
 */
public class NhomSanPhamDAOImpl extends HibernateDaoSupport implements NhomSanPhamDAO{

    @Override
    public void saveNhomSanPham(NhomSanPham nhomSanPham) {
        getHibernateTemplate().saveOrUpdate(nhomSanPham);
    }

    @Override
    public List<NhomSanPham> listNhomSanPham() {
       return getHibernateTemplate().find("from NhomSanPham");
    }

    @Override
    public String getTenNhomById(int id) {
        return (String)getSession().createQuery("select nhom.tenNhomSanPham from NhomSanPham nhom where nhom.id="+id)
                .list().toArray()[0];
    }

}
